<template>
  <Main
    :data="listData"
    :footer-lock="total > 10"
    @selection-change="handleSelectionChange"
  >
    <!-- <el-table-column
      type="selection"
      width="55"
      :selectable="checkSelectable"
    ></el-table-column> -->
    <el-table-column
      label="商品名称"
      align="center"
      property="goods_name"
    ></el-table-column>
    <el-table-column label="销售价格" align="center" property="peoples">
      <template slot-scope="scope">
        <span v-if="scope.row.low_goods_price == scope.row.up_goods_price"
          >￥{{ scope.row.low_goods_price }}</span
        >
        <span v-else
          >￥{{ scope.row.low_goods_price }} - ￥{{
            scope.row.up_goods_price
          }}</span
        >
      </template>
    </el-table-column>
    <el-table-column label="成本价格" align="center">
      <template slot-scope="scope">
        <span v-if="scope.row.low_cost == scope.row.up_cost"
          >￥{{ scope.row.low_cost }}</span
        >
        <span v-else
          >￥{{ scope.row.low_cost }} - ￥{{ scope.row.up_cost }}</span
        >
      </template>
    </el-table-column>
    <el-table-column label="商品状态" align="center">
      <template slot-scope="scope">
        <span v-if="scope.row.status == 'normal'">正常</span>
        <span v-if="scope.row.status == 'temporarily'">下架</span>
        <span v-if="scope.row.status == 'sell_out'">售罄</span>
      </template>
    </el-table-column>
    <el-table-column
      label="实际销量"
      align="center"
      property="goods_salecount"
    ></el-table-column>
    <el-table-column
      label="商品库存"
      align="center"
      property="goods_stock"
    ></el-table-column>

    <el-table-column
      label="操作"
      align="center"
      fixed="right"
      width="250"
      class-name="tableoperation"
    >
      <template slot-scope="scope">
        <el-button
          v-if="scope.row.flag == 0"
          size="mini"
          type="text"
          @click="add(scope.row)"
        >
          添加
        </el-button>
        <span v-if="scope.row.flag == 1">同一时间，已参加拼团</span>
        <span v-if="scope.row.flag == 2">同一时间，已参加限时折扣</span>
        <span v-if="scope.row.flag == 4">同一时间，已参加砍价</span>
      </template>
    </el-table-column>
  </Main>
</template>
<script>
export default {
  props: {
    listData: {
      type: Array,
      default: () => []
    },
    total: {
      type: Number,
      default: 0
    }
  },
  methods: {
    add(e) {
      this.$emit("returnVal", e, "add");
    },
    handleSelectionChange(v) {
      this.$emit("returnValAll", v, "add");
    },
    checkSelectable(row) {
      return row.flag === 0;
    }
  }
};
</script>
